home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-12-23 | 3.0 KB | 127 lines | [TEXT/MACA] |
- \ rfl sample use for class copier. A simple magnifying glass.
- \ need to load source 'offscreen' first
-
- :CLASS xferer <super copier
-
- var srcPort \ source port for copying from
- rect srcRect \ source rectangle for copying from
-
- :M sourceRect: put: srcRect ;M
- :M sourcePort: +base put: srcPort ;M
- :M drawDestRect: pushPort set: [ obj: destPort ]
- get: destRect put: temprect -1 -1 inset: temprect draw: temprect
- popPort ;M
-
- :M rowBytes: ( -- n) size: srcRect drop 15 + 4 >> 1 << ;M
-
- :M new: { \ myBitMap rows -- }
- open: self
- rowBytes: self -> rows \ calc rowbytes
- rows size: srcRect swap drop * \ calc size of bitmap
- heap> bitMap -> myBitMap \ create bitmap on heap
- rows get: srcRect put: myBitMap \ init bitmap
- myBitMap put: offScreen \ store pointer for disposing
- pushPort set: self \ set bitmap to grafport
- myBitMap +base call setPortBits
- get: srcRect ^base 16 + put: rect
- popPort ;M
-
- :M save: obj: srcPort 2+ ^base 2+ +base
- abs: srcRect (abs) 16 +
- word0 0 call copyBits ;M \ write over previous
-
- :M offsetDest: ( dx dy -- ) offset: destRect ;M
- :M offsetSource: ( dx dy -- ) offset: srcrect ;M
-
- :M moveDestTo: { x y -- } x getTopX: destRect - y getTopY: destRect -
- offset: destRect ;M
- :M moveSourceTo: { x y -- } x getTopX: srcrect - y getTopY: srcrect -
- offset: srcrect ;M
-
- ;CLASS
-
- :CLASS funnyWind <super window
-
- \ hold down option key during content click to move window
- :M CONTENT: mods: fevent $ 800 and
- IF abs: self where: fevent -1000 dup 1000 dup put: temprect
- abs: temprect call dragWindow
- ELSE exec: content
- THEN ;M
-
- :M NEW: grayRgn true setDrag: self
- 100 200 156 256 put: temprect
- temprect 0 0 dlgWind true true new: super ;M
-
- ;CLASS
-
-
- \ since we don't have a resource file definition, define a cursor class.
- :CLASS MCursor <super warray
-
- :M set: idxBase +base call setCursor ;M
-
- ;CLASS
-
- 34 MCursor squareCurs
-
- \ load with bits for a square cursor
- hex
- 0000 0000 7ffc 4004
- 4004 4004 4004 4004
- 4004 4004 4004 4004
- 4004 4004 7ffc 0000
-
- 0000 fffe fffe c006
- c006 c006 c006 c006
- c006 c006 c006 c006
- c006 c006 fffe fffe
- 0008 0007
-
- decimal
-
- put: squareCurs
-
- xferer bob
- funnyWind suz
-
- new: suz
-
- \ don't have a resource file here
- \ " magnify" openresfile
-
- 0 0 55 55 destrect: bob
- 0 0 11 11 sourceRect: bob
- fwind sourcePort: bob
- suz destPort: bob
- new: bob
- set: fwind
-
- \ If we had a cursor defined in a resource file, with ID=1000
- \ we could just say: '1000 cursor magcurs', and not have to define
- \ class MCursor
-
- : magCurs set: squareCurs ;
-
-
- \ one way to execute a magnifier is to hold the mouse button down
- : magnify magcurs
- BEGIN
- where: theMouse 5 - swap 5 - swap moveSourceto: bob
- save: bob draw: bob
- stilldown? not
- UNTIL arrowcurs ;
-
- 4 'cfas null null null magnify actions: fwind
-
- \ load this for another way
- \ : magnify2 getRect: fwind put: temprect
- \ word0 where: theMouse pack abs: temprect call ptInRect i->l
- \ IF magCurs where: theMouse 5 - swap 5 - swap moveSourceto: bob
- \ save: bob draw: bob
- \ ELSE arrowcurs
- \ THEN ;
- \
- \ 'c magnify2 setidle: fwind
-
-